package com.song.statisticsservice.controller;


import com.song.commonutils.ResultObj;
import com.song.statisticsservice.client.UcenterFeign;
import com.song.statisticsservice.service.StatisticsDailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author song
 * @since 2020-04-07
 */
@RestController
@RequestMapping("/statisticsservice/statisticsdaily")
public class StatisticsDailyController {


    @Autowired
    StatisticsDailyService statisticsDailyService;


    /**
     * 统计某一天的注册人数
     *
     * @param day
     * @return
     */
    @ApiOperation("某一天的注册人数")
    @PostMapping("/countRegister/{day}")
    public ResultObj countRegister(@PathVariable("day") String day) {
        statisticsDailyService.countRegister(day);
        return ResultObj.ok();
    }

    /**
     * 图表显示
     *
     * @param type
     * @param begin
     * @param end
     * @return
     */
    @ApiOperation("图表显示")
    @GetMapping("/showData/{type}/{begin}/{end}")
    public ResultObj show(@PathVariable String type,
                          @PathVariable String begin,
                          @PathVariable String end) {
        Map<String,Object> map =statisticsDailyService.showData(type, begin, end);
        return ResultObj.ok().data(map);
    }
}

